<?php

namespace App\Http\Controllers;

use App\Repositories\GameRepository;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class GameController extends Controller
{
    protected $gameRepository;
    public function __construct()
    {
        $this->gameRepository=new GameRepository();
    }

    public function index(){
        //dd(11);
        $user=Auth::guard('member')->user();
        $game=$this->gameRepository->game(1);
        $record=$this->gameRepository->getRecord(1);
        return view('web.game.index',compact('game','user','record'));
    }
    public function run(Request $request){
        //暂定只有老虎机
        if(!$this->gameRepository->decrementGameNum(Auth::guard('member')->user())){
            return [
                'info'=>'error',
                'msg'=>'余额不足，请充值',
            ];
        }
       return  $this->gameRepository->reward(1);
    }
    public function tetris(){
        $user=Auth::guard('member')->user();

        return view('web.game.sbmao',compact('user'));
    }


}
